package com.designpatterns.iterator.define;

import java.util.ArrayList;

/**
 * @author Brook
 */
public class PancakeHoseIterator implements Iterator{
    ArrayList<MenuItem> items;
    int position = 0;

    public PancakeHoseIterator(ArrayList<MenuItem> menuItems) {
        this.items = menuItems;
    }

    @Override
    public boolean hasNext() {
        return position < items.size() && items.get(position) != null;
    }

    @Override
    public Object next() {
        MenuItem menuItem = items.get(position);
        position = position + 1;
        return menuItem;
    }
}
